package com.codestudy.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private com.codestudy.interceptor.LoginCheckInterceptor loginCheckInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("addINterceptors:" + loginCheckInterceptor);
        registry.addInterceptor(loginCheckInterceptor)
                .addPathPatterns("/comment/**", "/likes/**", "/note/**", "/upload/**", "/user/**"); //拦截指定路径;
        // 或者指定特定路径
//                .addPathPatterns("/api/**")
        // 可以排除不需要验证Token的路径
//                .excludePathPatterns("/dist","/dist/**","/build","/build/**","/web","/web/**","/login", "/regedit", "/static/**", "/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**", "/doc.html/**", "/error","/favicon.ico","8.138.160.82:8090/","/static","/static/**");
    }

//    @Autowired
//    private LoginCheckInterceptor loginCheckInterceptor;
//    @Autowired
//    private LoginCheckInterceptor loginCheckInterceptor;
}
